Skip to content

fix(51301): Fixing an unused import at the end of a line removes the newline#51320

Merged
DanielRosenwasser merged 5 commits into
microsoft:mainfrom
a-tarasyuk:fix/51301
Oct 28, 2022
Merged

fix(51301): Fixing an unused import at the end of a line removes the newline#51320
DanielRosenwasser merged 5 commits into
microsoft:mainfrom
a-tarasyuk:fix/51301

Conversation

@a-tarasyuk

Copy link
Copy Markdown
Contributor

Fixes #51301

@typescript-bot typescript-bot added the For Milestone Bug PRs that fix a bug with a specific milestone label Oct 26, 2022
@a-tarasyuk a-tarasyuk marked this pull request as draft October 26, 2022 19:09
@jakebailey

Copy link
Copy Markdown
Member

I think you're hitting exactly the problem I was when I tried to quick fix this 😅

@a-tarasyuk a-tarasyuk marked this pull request as ready for review October 26, 2022 19:59
@a-tarasyuk

Copy link
Copy Markdown
Contributor Author

😇

@jakebailey

Copy link
Copy Markdown
Member

I tried to fix this last night and you figured out that second hurdle (which is where I gave up). Nice!

This seems fine to me, but I have no idea what's good/bad for this part of the code.

@jakebailey

jakebailey commented Oct 26, 2022

Copy link
Copy Markdown
Member

FWIW this is a related case that I think is also this same bug:

function foo(
    a: number, b: number,
    c: number,
) {
    return a + c;
}

Removing b also behaves the same way. Should we be always preserving the newlines? Or are there cases where this turns out to matter?

I don't mind a targeted fix, of course. Would be great to have this in 4.9.

@jakebailey

Copy link
Copy Markdown
Member

Thanks for the added tests. I think one could also do the same thing as parameters for type parameters as well. I've modified the PR to eliminate the new parameter (make it always true) and everything passes, which does seem to match my intuition.

@jakebailey jakebailey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems correct to me, but interested in what others think.

@DanielRosenwasser DanielRosenwasser merged commit 64d0d5a into microsoft:main Oct 28, 2022
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Milestone Bug PRs that fix a bug with a specific milestone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fixing an unused import at the end of a line removes the newline

4 participants